//
//  BaseViewController.m
//  FruitsWholesaler
//
//  Created by sgone-2 on 15/11/16.
//  Copyright © 2015年 sgone. All rights reserved.
//

#import "BaseViewController.h"
#import "Common.h"
#import "MBProgressHUD+MJ.h"
#import "MBProgressHUD.h"

@interface BaseViewController ()

@end

@implementation BaseViewController


-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;

}

- (void)viewDidLoad {
    [super viewDidLoad];

 
   
    
    

    if (IOS_VERSION >= 7.0) {
        self.automaticallyAdjustsScrollViewInsets = NO;
       
    }
    
    self.view.backgroundColor = BACKGROUND1;
    //    //设置状态栏的字体颜色为白色
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    
    self.dataHandler = [DataSingleton sharedDataSingleton];
    if (!self.isTopView) {
       self.topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ViewWidth, 64)];
        self.topView.backgroundColor = BenSe_COLOR;
        [self.view addSubview:self.topView];
        
   
        
        self.titleLabel = [[UILabel alloc]init];
        [self.titleLabel sizeToFit];
        self.titleLabel.frame = CGRectMake(0, 10, 125, 30);
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
//        self.titleLabel.center = self.topView.center;
        
        self.titleLabel.center = CGPointMake(self.topView.bounds.size.width/2, self.topView.bounds.size.height-24);
        self.titleLabel.backgroundColor = [UIColor clearColor];
        self.titleLabel.textColor = [UIColor whiteColor];
//         self.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        [self.topView addSubview:self.titleLabel];
    }

//    if(self.isBackBut == YES)
//    {
    
        self.backBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.backBtn addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
        [self.backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [self.backBtn setFrame:CGRectMake(0, 20, 44, 44)];
        [self.topView addSubview:self.backBtn];
        self.backBtn.hidden = YES;
        
    
    
    
    
    
//    }
   
//    if (self.isRightBut == YES) {
        self.rightBut=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.rightBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.rightBut.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.rightBut addTarget:self action:@selector(rightButClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.rightBut setFrame:CGRectMake(ViewWidth *0.82, 18, 70, 44)];
        [self.topView addSubview:self.rightBut];
//        self.rightBut.backgroundColor = [UIColor greenColor];
        self.rightBut.hidden = YES;
//    }
}

- (void)back:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
    
    
}


- (void)rightButClick:(id)sender {
    
    

    
}

@end
